<?php
/**
 * 通用微信公众号网页授权
 * Author: ZeonWang
 * Date: 2017/11/28
 * Time: 14:51
 * Created by PhpStorm.
 */

use App\Http\Controllers\OpenWechat\OAuthController;
use Illuminate\Support\Facades\Route;

/**
 * @see \App\Providers\RouteServiceProvider::initMacros()
 * @see \App\Http\Controllers\CorsController::preFlightCheck()
 */
Route::corsAny();

/**
 * 获取当前 session 的 openid
 *
 * @see OAuthController::openid()
 */
Route::get('openid','OAuthController@openid');

/**
 * 获取当前 session 的 user info
 *
 * @see OAuthController::userInfo()
 */
Route::get('user-info','OAuthController@userInfo');

/**
 * 微信授权
 *
 * @see OAuthController::oauth()
 */
Route::any('oauth','OAuthController@oauth')
    ->name(OAuthController::OAUTH_ROUTE);

/**
 * 授权成功后回调处理
 *
 * @see OAuthController::oauthCallBack()
 */
Route::any('oauth-callback','OAuthController@oauthCallBack')
    ->name(OAuthController::OAUTH_CALL_BACK_ROUTE);

/**
 * 使用 openid 获取当前微信用户
 *
 * @see \App\Http\Controllers\OpenWechat\WechatUserController::showByOpenid()
 */
Route::get('wechat-user/{open_id}','WechatUserController@showByOpenid');